package com.aaa.home.service.Impl;

import com.aaa.common.entity.AclPermission;
import com.aaa.common.entity.home.EduCourse;
import com.aaa.common.entity.home.TblZone;
import com.aaa.common.vo.Result;
import com.aaa.home.dao.TbZoneCourseDao;
import com.aaa.home.service.TbZoneCourseService;
import com.aaa.home.vo.Zone.ZoneCourseVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * @author ：Mickey
 * @date ：Created in 2022/12/10 11:31
 * @description：
 * @modified By：
 * @version:
 */
@Service
public class TbZoneCourseServiceImpl implements TbZoneCourseService {

    @Autowired
    private TbZoneCourseDao zoneCourseDao;

    //根据专区Id查询专区课程（无分页）
    @Override
    public Result getAllZonePage(ZoneCourseVo zoneCourseVo, Integer current, Integer pageSize) {
        List<EduCourse> eduCourses = zoneCourseDao.selectByZoneid(zoneCourseVo.getZoneId());
        IPage<EduCourse> page = new Page<>(current, pageSize);
        QueryWrapper<EduCourse> wrapper = new QueryWrapper<>();
        System.out.println(eduCourses+"lllllllllllllllllllllll");
        if(StringUtils.hasText(zoneCourseVo.getCourseTitle())){
            wrapper.like("title",zoneCourseVo.getCourseTitle());
        }
        if (zoneCourseVo.getIsDeleted()!=null){
            wrapper.eq("is_deleted",zoneCourseVo.getIsDeleted());
        }
//        for(EduCourse eduCourses1 : eduCourses) {
//            wrapper.eq("id",eduCourses1.getId());
//        }
        IPage<EduCourse> page1 = zoneCourseDao.selectPage(page,wrapper);
        System.out.println(page1+"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
//        return new Result(2000,"分页查询专区成功",page1);
        return new Result<List<EduCourse>>(2000, "查询成功", eduCourses);
    }
}
